home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include "global.h"
- #include "mbuf.h"
- #include "timer.h"
- #include "arp.h"
-
- #ifdef MAC
- extern int tcptrcflg;
- extern FILE *trcwndp;
- #endif
-
- arp_dump(bpp)
- struct mbuf **bpp;
- {
- struct arp arp;
- char *inet_ntoa();
- struct arp_type *at;
- int is_ip = 0;
-
- if(bpp == NULLBUFP || *bpp == NULLBUF)
- return;
- #ifdef MAC
- fprintf(trcwndp,"ARP: len %d",len_mbuf(*bpp));
- if(ntoharp(&arp,bpp) == -1){
- fprintf(trcwndp," bad packet\n");
- return;
- }
- /* Print hardware type in Ascii if known, numerically if not */
- if(arp.hardware < NHWTYPES){
- at = &arp_type[arp.hardware];
- fprintf(trcwndp," hwtype %s",arptypes[arp.hardware]);
- } else {
- at = NULLATYPE;
- fprintf(trcwndp," hwtype %u",arp.hardware);
- }
- /* Print hardware length only if unknown type, or if it doesn't match
- * the length in the known types table
- */
- if(at == NULLATYPE || arp.hwalen != at->hwalen)
- fprintf(trcwndp," hwlen %u",arp.hwalen);
-
- /* Check for most common case -- upper level protocol is IP */
- if(at != NULLATYPE && arp.protocol == at->iptype){
- fprintf(trcwndp," prot IP");
- is_ip = 1;
- } else {
- fprintf(trcwndp," prot 0x%x prlen %u",arp.protocol,arp.pralen);
- }
- switch(arp.opcode){
- case ARP_REQUEST:
- fprintf(trcwndp," op REQUEST");
- break;
- case ARP_REPLY:
- fprintf(trcwndp," op REPLY");
- break;
- default:
- fprintf(trcwndp," op %u",arp.opcode);
- break;
- }
- if(is_ip)
- fprintf(trcwndp," target %s",inet_ntoa(arp.tprotaddr));
- fprintf(trcwndp,"\n");
- #else
- printf("ARP: len %d",len_mbuf(*bpp));
- if(ntoharp(&arp,bpp) == -1){
- printf(" bad packet\n");
- return;
- }
- /* Print hardware type in Ascii if known, numerically if not */
- if(arp.hardware < NHWTYPES){
- at = &arp_type[arp.hardware];
- printf(" hwtype %s",arptypes[arp.hardware]);
- } else {
- at = NULLATYPE;
- printf(" hwtype %u",arp.hardware);
- }
- /* Print hardware length only if unknown type, or if it doesn't match
- * the length in the known types table
- */
- if(at == NULLATYPE || arp.hwalen != at->hwalen)
- printf(" hwlen %u",arp.hwalen);
-
- /* Check for most common case -- upper level protocol is IP */
- if(at != NULLATYPE && arp.protocol == at->iptype){
- printf(" prot IP");
- is_ip = 1;
- } else {
- printf(" prot 0x%x prlen %u",arp.protocol,arp.pralen);
- }
- switch(arp.opcode){
- case ARP_REQUEST:
- printf(" op REQUEST");
- break;
- case ARP_REPLY:
- printf(" op REPLY");
- break;
- default:
- printf(" op %u",arp.opcode);
- break;
- }
- if(is_ip)
- printf(" target %s",inet_ntoa(arp.tprotaddr));
- printf("\n");
- #endif
- }
-
-